package com.shenfa.action;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;

import com.shenfa.bean.NetServer;
import com.shenfa.service.NetServerService;

import com.shenfa.util.ResultObject;

/**
 * NetServer参数ACTION
 * 
 * @author yanglong
 *
 */
@SuppressWarnings("serial")
public class NetServerAction extends BaseAction {

	@Autowired
	private NetServerService netServerService;
	
	private NetServer netServer;
	private static Logger log=Logger.getLogger(NetServerAction.class);
	
	/**
	 * 根据对象条件查询NetServer参数列表
	 * @return
	 */
	private int start;
	private int limit;

	@SuppressWarnings("unchecked")
	public String queryList(){	
		log.debug("netServer="+netServer+",start="+start+",limit="+limit);
		List<NetServer> list = netServerService.queryList(netServer, start, limit);
		result = ResultObject.build("0", list);
		result.put("total", netServerService.queryCount(netServer));
		return SUCCESS;
	}
	
	/**
	 * NetServer服务操作
	 * @return
	 */
	public String operServer(){	
		String flag = netServerService.operServer(netServer);
		result = ResultObject.build("0", flag);
		return SUCCESS;
	}
	
	/**
	 * 添加NetServer参数信息
	 * @return	1成功，0失败
	 */
	public String add(){
		log.debug(netServer.toString());
		int type = netServerService.add(netServer);
		if(type == 1){
			result = ResultObject.build(String.valueOf(type), "添加成功！");
		} else {
			result = ResultObject.build(String.valueOf(type), "操作失败！");
		}
		return SUCCESS;
	}
	
	/**
	 * 删除NetServer参数信息
	 * @return	1成功，0失败
	 */
	public String del(){
		log.debug(netServer.toString());
		int type = netServerService.del(netServer);
		if(type == 1){
			result = ResultObject.build(String.valueOf(type), "删除成功！");
		} else {
			result = ResultObject.build(String.valueOf(type), "操作失败！");
		}
		return SUCCESS;
	}
	
	/**
	 * 修改NetServer参数信息
	 * @return	1成功，0失败
	 */
	public String upd() {
		log.debug(netServer.toString());
		int type = netServerService.upd(netServer);
		if(type == 1){
			result = ResultObject.build(String.valueOf(type), "修改成功！");
		} else {
			result = ResultObject.build(String.valueOf(type), "操作失败！");
		}
		return SUCCESS;
	}

	public NetServer getNetServer() {
		return netServer;
	}

	public void setNetServer(NetServer netServer) {
		this.netServer = netServer;
	}
	
	public void setStart(int start) {
		this.start = start;
	}

	public void setLimit(int limit) {
		this.limit = limit;
	}
}
